package com.example.crm.service;

import com.example.crm.entity.Right;
import com.example.crm.entity.Role;
import com.example.crm.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;

/**
 * @author lenovo
 */
public interface IRoleService {
    /**
     * 角色增删改查
     * @return
     */
    public List<Role> findAllRoles();

    /**
     * 权限查询
     * @return
     */
    public List<Right> findAllRights();

    /**
     * 根据role查询权限
     * @param role
     * @return
     */
    public List<Right> findRightsByRole(Role role);

    /**
     * 新增或修改
     * @param role
     * @return
     */
    public Role saveRole(Role role);

    /**
     * 删除
     * @param roleId
     */
    public void deleteRoleById(Long roleId);

    /**
     * 删除
     * @param role
     */
    public void deleteRole(Role role);

    /**
     * 按主键查询单条
     * @param roleId
     * @return
     */
    public Role getRole(Long roleId);

    /**
     * 按名称模糊查询并分页
     * @param roleName
     * @param pageable
     * @return
     */
    public Page<Role> findRole(String roleName, Pageable pageable);

    /**
     * 根据用户名查询角色对象
     * @param user
     * @return
     */
    public Role findRoleByUsers(User user);

    public void reloadFilterChainDefinitions();
}